<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Wind Speed Chart</title>
    <!-- 引入Chart.js库 -->
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body>
<canvas id="chart-line-md" width="800" height="400"></canvas>

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
<script src="assets/js/jquery.min.js"></script>
<script>
    // 使用 jQuery 发起 GET 请求
    $.get("https://api.caiyunapp.com/v2.6/geXvUYKbameLHlol/101.6656,39.2072/realtime", function (response) {
        // 解析响应数据
        var apiData = JSON.parse(response);

        // 获取 wind.speed 数据
        var windSpeedData = apiData.result.wind.speed;

        // 将数据映射到 t 和 y 属性
        var data_line = windSpeedData.map(obj => {
            return {
                t: obj.datetime,
                y: obj.value
            };
        });

        // 在控制台打印映射后的数据
        console.log(data_line);
    });
</script>
</body>
</html>
